package com.neuedu.dao.imp;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import com.neuedu.bean.User;
import com.neuedu.dao.IUser;
import com.neuedu.util.Sqlutil;

public class UserImpl implements IUser {

	@Override
	public List<User> selectAll() {
		Connection conn=null;
		PreparedStatement pstm=null;
		ResultSet rs=null;
		List<User> listu=new ArrayList<>();
		
		try {
			conn=Sqlutil.getConn();
			String sql="select * from t_use";
			pstm=conn.prepareStatement(sql);
			rs=pstm.executeQuery();
			while(rs.next()) {
				User u=new User();
				u.setUid(rs.getInt("u_id"));
				u.setUname(rs.getString("u_name"));
				u.setUpwd(rs.getString("u_pwd"));
				u.setUsex(rs.getString("u_sex"));
				listu.add(u);
			}
		} catch (Exception e) {
		
			e.printStackTrace();
		}finally {
			Sqlutil.close(rs,pstm,conn);
		}
		
		
		
		return listu;
	}

}
